Dynomotion

Group: DynoMotion Message: 10116 From: engnerdan Date: 9/4/2014
Subject: Tapping in KmotionCNC

Tom,

What types of tapping are supported in KmotionCNC? I only find reference to doing rigid tapping with Mach3. I am using the EMC post processor for my CAM software and it kicks out a G33.1 which KmotionCNC doesn't like. 


-Dan

Group: DynoMotion Message: 10119 From: Tom Kerekes Date: 9/4/2014
Subject: Re: Tapping in KmotionCNC
Hi Dan,

A Rigid Tapping G code is not currently supported in KMotionCNC.  Actually there is code in KMotionCNC for G84 that is coded to make several spindle synchronized moves, but I don't think that would work well.

We would probably be willing to add that built in functionality into KMotionCNC if we can agree on the syntax and you are willing to help debug.  It seems like G84 is more standard on Fanuc and Haas.  Mach3 uses it for Floating Tapping.

Of course you can use #Var Parameters, an MCode, and a User C Program to Rigid Tap now in the same manner as Mach3.  The C Program would need to be modified slightly to read the parameters rather than having Mach3 write them to UserData Memory.  I can do that for you if you wish.  Getting that to work correctly would be first step regardless.

Regards
TK

Group: DynoMotion Message: 10140 From: Dan Date: 9/5/2014
Subject: Re: Tapping in KmotionCNC
Tom,
I am game to help with this, I have done a fair amount of research into this. I will send another email when I have time in the next couple days and let you know my thoughts on this. But I would be glad to help how ever I can.
 
Dan
 
Sent: Thursday, September 04, 2014 12:15 PM
Subject: Re: [DynoMotion] Tapping in KmotionCNC
 
 

Hi Dan,

A Rigid Tapping G code is not currently supported in KMotionCNC.  Actually there is code in KMotionCNC for G84 that is coded to make several spindle synchronized moves, but I don't think that would work well.

We would probably be willing to add that built in functionality into KMotionCNC if we can agree on the syntax and you are willing to help debug.  It seems like G84 is more standard on Fanuc and Haas.  Mach3 uses it for Floating Tapping.
 
Of course you can use #Var Parameters, an MCode, and a User C Program to Rigid Tap now in the same manner as Mach3.  The C Program would need to be modified slightly to read the parameters rather than having Mach3 write them to UserData Memory.  I can do that for you if you wish.  Getting that to work correctly would be first step regardless.
 
Regards
TK
 
Group: DynoMotion Message: 10179 From: Dan Date: 9/17/2014
Subject: Re: Tapping in KmotionCNC
Attachments :

    Tom,

    I have been swamped with work, school and getting ready for a wedding so this is a bit delayed. Here is what I have so far. I could be wrong but I don’t think it will take a ton of work on your end in coding to make this happen. I need to find some more info on the structure of the G84 command (how it is put together in the g-code file). But from the small amount I know I think it follows the convention of most other canned cycles.

    I can test your code when you get it done, but I have one small hangup right now. My spindle motor went up in smoke last week and I am running on a temporary motor. So I will not be able to do any rigid tapping testing until the new motor comes and I get an encoder installed.

     

     

     

    I did a fair amount of internet searching and talked to a few friends who program CNC’s daily. Here is a compilation of what I have found.

    G Codes for tapping

    G33.1

    G33.2

    G74 – Non rigid tapping Left Hand

    G74.1 – Rigid Tapping Left Hand -

    G.84 – Generic Tapping G-Code

    G84.1 – Right hand Rigid tapping - Mazak

    G84.2 – Right Hand rigid tapping

    G84.3 – Left hand Rigid tapping

    Plus there may be more and there are combinations of G-codes to comprise different tapping cycles. Write or wrong I am thinking either we use just G74 and G84 or have it a programmable value for an initialization file. Where the end user would tell the KFLOP which G-code is left hand and which is right hand.

     

    The next thing I found was the F value of the canned cycle can have 2 different values. One version has the F value equal to the thread pitch (1/4-20 would be 0.050”). The second F value is an actual inches per minute for the Z axis. This would be calculated by multiplying the thread pitch times the spindle RPM.

     

    The next variable is the type of tapping, old school tapping would have been done with a automatically reversing tapping head. The spindle turns clockwise the entire cycle and the tapping head reverses when the Z axis retracts. Then there is the tension & compression tapping head that allows for a non-synchronized Z axis feed. The last type is rigid tapping.

     

    I am thinking that we use the generic G74 and G84 G-Codes like I mentioned before. Then you add a set of parameters to configure the controller to the type of tapping that the user wants to do. Something like this is what I a picturing.

    Menu Idea

     

    The G-Code in the program should look something like this, just like most other canned routines.

    Denford G84 Tapping Cycle

     

    If the user picks option

    A1 –     Z axis is not geared to the spindle

                G84 – Spindle turns clockwise for Z – move

                G84 – Spindle turns clockwise for Z+ move

                G74 – Not sure if tapping head supports this?

     

    A2-        Z axis is not geared to the spindle

                G84 – Spindle turns clockwise for Z – move

                G84 – Spindle turns counter clockwise for Z+ move

                G74 – Spindle turns counter clockwise for Z- move

                G74 – Spindle turns clockwise for Z+ move

     

    A3-        Z axis is geared to the spindle

                G84 – Spindle turns clockwise for Z – move

                G84 – Spindle turns counter clockwise for Z+ move

                G74 – Spindle turns counter clockwise for Z- move

                G74 – Spindle turns clockwise for Z+ move

    Dan
     
    Group: DynoMotion Message: 10196 From: Dan Date: 9/24/2014
    Subject: Re: Tapping in KmotionCNC
    Attachments :
      Tom,
      Just a little update, I have 2 spindle motors on the way to me and I am going to order some optical encoders this afternoon. But I want to verify something with you first.
       
      I have a 6000 RPM and a 8000 RPM motor coming, I was planning on using 1000 line optical encoders. I think you said the sampling rate for the encoder channels is 1Mhz, is tat correct? I want to verify how that sampling works.
       
      6000 RPM motor with a 1000 line encoder (4000 line w quadrature)
      6000 RPM/ 60 Seconds = 100 Rotations per second
      100 Rotations per second * 1000 lines per rotation = 100,000hz or 100Khz single rate per channel
       
      So the sampling needed for this setup is only 100Khz correct? The 4X multiplication for the quadrature happens after the signal is sampled, right? Or is the sampling needed 200Khz because the rising and falling edge need to be detected?
       
       
      Dan
       
      Sent: Wednesday, September 17, 2014 8:36 AM
      Subject: Re: [DynoMotion] Tapping in KmotionCNC
       
       

      Tom,

      I have been swamped with work, school and getting ready for a wedding so this is a bit delayed. Here is what I have so far. I could be wrong but I don’t think it will take a ton of work on your end in coding to make this happen. I need to find some more info on the structure of the G84 command (how it is put together in the g-code file). But from the small amount I know I think it follows the convention of most other canned cycles.

      I can test your code when you get it done, but I have one small hangup right now. My spindle motor went up in smoke last week and I am running on a temporary motor. So I will not be able to do any rigid tapping testing until the new motor comes and I get an encoder installed.

       

       

       

      I did a fair amount of internet searching and talked to a few friends who program CNC’s daily. Here is a compilation of what I have found.

      G Codes for tapping

      G33.1

      G33.2

      G74 – Non rigid tapping Left Hand

      G74.1 – Rigid Tapping Left Hand -

      G.84 – Generic Tapping G-Code

      G84.1 – Right hand Rigid tapping - Mazak

      G84.2 – Right Hand rigid tapping

      G84.3 – Left hand Rigid tapping

      Plus there may be more and there are combinations of G-codes to comprise different tapping cycles. Write or wrong I am thinking either we use just G74 and G84 or have it a programmable value for an initialization file. Where the end user would tell the KFLOP which G-code is left hand and which is right hand.

       

      The next thing I found was the F value of the canned cycle can have 2 different values. One version has the F value equal to the thread pitch (1/4-20 would be 0.050”). The second F value is an actual inches per minute for the Z axis. This would be calculated by multiplying the thread pitch times the spindle RPM.

       

      The next variable is the type of tapping, old school tapping would have been done with a automatically reversing tapping head. The spindle turns clockwise the entire cycle and the tapping head reverses when the Z axis retracts. Then there is the tension & compression tapping head that allows for a non-synchronized Z axis feed. The last type is rigid tapping.

       

      I am thinking that we use the generic G74 and G84 G-Codes like I mentioned before. Then you add a set of parameters to configure the controller to the type of tapping that the user wants to do. Something like this is what I a picturing.

      Menu Idea

       

      The G-Code in the program should look something like this, just like most other canned routines.

      Denford G84 Tapping Cycle

       

      If the user picks option

      A1 –     Z axis is not geared to the spindle

                  G84 – Spindle turns clockwise for Z – move

                  G84 – Spindle turns clockwise for Z+ move

                  G74 – Not sure if tapping head supports this?

       

      A2-        Z axis is not geared to the spindle

                  G84 – Spindle turns clockwise for Z – move

                  G84 – Spindle turns counter clockwise for Z+ move

                  G74 – Spindle turns counter clockwise for Z- move

                  G74 – Spindle turns clockwise for Z+ move

       

      A3-        Z axis is geared to the spindle

                  G84 – Spindle turns clockwise for Z – move

                  G84 – Spindle turns counter clockwise for Z+ move

                  G74 – Spindle turns counter clockwise for Z- move

                  G74 – Spindle turns clockwise for Z+ move

      Dan
       
      Group: DynoMotion Message: 10201 From: Tom Kerekes Date: 9/24/2014
      Subject: Re: Tapping in KmotionCNC
      Hi Dan,

      Actually KFLOP samples the A B Quadrature lines at 16.67MHz and performs programmable filtering and counts quadrature transitions (counts).  The main limitation is that only +/-127 quadrature transitions can be counted per servo sample time of 90us.  This comes out to about 1.4M quadrature counts/sec.  We spec 1.0M quadrature counts/sec which is 250K encoder lines/sec. 

      You should be good.

      Regards
      TK

       

      Group: DynoMotion Message: 10491 From: Tom Kerekes Date: 11/11/2014
      Subject: Re: Tapping in KmotionCNC [2 Attachments]
      Hi Dan,

      I'm not familiar with a tension/compression head.  I'm assuming it provides some Z compliance so that exact synchronization is not required?

      I think we could use the same Rigid Tapping sequence for it.  If you don't have spindle feedback we could still used synchronized Z motion the same as if we did,  but just modify the code slightly to assume the actual Spindle Position is the same as the commanded Spindle Position.   The C Program here uses the commanded Spindle position (Dest) to slave the Z Motion.


      Let's get "Rigid" tapping to work first calling a C Prbefore we begin modifying the Interpreter.  This process will need to be modified to work with KMotionCNC instead of Mach3.  The Process just involves downloading the parameters for the Tap and then running the C Program Tap sequence.  KFLOP can simply read the GCode Var Parameters directly so there is no need to put them in DROs and download them the way the Mach3 process works.

      I forget how your Spindle is controlled.  Before we do anything we will need to configure things (open loop?) in a manner that we can tell the Spindle Axis to Move a certain amount (few revs) and then reverse a certain amount and it should move that amount approximately.  Do you know how to do this?

      Let me know how much of this makes sense.

      Regards
      TK






      Tom,
      Have you had any time to look into the tapping code? Even if the rigid tapping did not get worked out yet support for G84 and G74 for a tapping head or tension and compression tap head would be great. Right now I am using a Procunier tapping head and using a G85 and a reaming cycle. This works but the tapping head is huge and limits the size of part I can tap. To use a tension and compression tapping head the same canned cycle as G85 would work as a starting point and then reverse the spindle when the Z depth is reached. Then flip the spindle back to the original direction once the machine has reached the retract plane.
       
      If you do not have time to work on this right now, can you tell me what code file/s handle the processing of the G code canned cycles? Maybe I can give it a whirl.
       
      As for development of the rigid tapping code, I still have not been able to get my motor with encoder modified and installed. I am hoping by the first of the year now.
       
      Thanks,
      Dan


      From: "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com>
      To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
      Sent: Wednesday, September 24, 2014 10:18 AM
      Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]

       
      [Attachment(s) from Tom Kerekes included below]
      Hi Dan,

      Actually KFLOP samples the A B Quadrature lines at 16.67MHz and performs programmable filtering and counts quadrature transitions (counts).  The main limitation is that only +/-127 quadrature transitions can be counted per servo sample time of 90us.  This comes out to about 1.4M quadrature counts/sec.  We spec 1.0M quadrature counts/sec which is 250K encoder lines/sec. 

      You should be good.

      Regards
      TK

       


      From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
      To: DynoMotion@yahoogroups.com
      Sent: Wednesday, September 24, 2014 5:36 AM
      Subject: Re: [DynoMotion] Tapping in KmotionCNC

       
      Tom,
      Just a little update, I have 2 spindle motors on the way to me and I am going to order some optical encoders this afternoon. But I want to verify something with you first.
       
      I have a 6000 RPM and a 8000 RPM motor coming, I was planning on using 1000 line optical encoders. I think you said the sampling rate for the encoder channels is 1Mhz, is tat correct? I want to verify how that sampling works.
       
      6000 RPM motor with a 1000 line encoder (4000 line w quadrature)
      6000 RPM/ 60 Seconds = 100 Rotations per second
      100 Rotations per second * 1000 lines per rotation = 100,000hz or 100Khz single rate per channel
       
      So the sampling needed for this setup is only 100Khz correct? The 4X multiplication for the quadrature happens after the signal is sampled, right? Or is the sampling needed 200Khz because the rising and falling edge need to be detected?
       
       
      Dan
       


      Sent: Wednesday, September 17, 2014 8:36 AM
      Subject: Re: [DynoMotion] Tapping in KmotionCNC
       
       
      Tom,
      I have been swamped with work, school and getting ready for a wedding so this is a bit delayed. Here is what I have so far. I could be wrong but I don’t think it will take a ton of work on your end in coding to make this happen. I need to find some more info on the structure of the G84 command (how it is put together in the g-code file). But from the small amount I know I think it follows the convention of most other canned cycles.
      I can test your code when you get it done, but I have one small hangup right now. My spindle motor went up in smoke last week and I am running on a temporary motor. So I will not be able to do any rigid tapping testing until the new motor comes and I get an encoder installed.
       
       
       
      I did a fair amount of internet searching and talked to a few friends who program CNC’s daily. Here is a compilation of what I have found.
      G Codes for tapping
      G33.1
      G33.2
      G74 – Non rigid tapping Left Hand
      G74.1 – Rigid Tapping Left Hand -
      G.84 – Generic Tapping G-Code
      G84.1 – Right hand Rigid tapping - Mazak
      G84.2 – Right Hand rigid tapping
      G84.3 – Left hand Rigid tapping
      Plus there may be more and there are combinations of G-codes to comprise different tapping cycles. Write or wrong I am thinking either we use just G74 and G84 or have it a programmable value for an initialization file. Where the end user would tell the KFLOP which G-code is left hand and which is right hand.
       
      The next thing I found was the F value of the canned cycle can have 2 different values. One version has the F value equal to the thread pitch (1/4-20 would be 0.050”). The second F value is an actual inches per minute for the Z axis. This would be calculated by multiplying the thread pitch times the spindle RPM.
       
      The next variable is the type of tapping, old school tapping would have been done with a automatically reversing tapping head. The spindle turns clockwise the entire cycle and the tapping head reverses when the Z axis retracts. Then there is the tension & compression tapping head that allows for a non-synchronized Z axis feed. The last type is rigid tapping.
       
      I am thinking that we use the generic G74 and G84 G-Codes like I mentioned before. Then you add a set of parameters to configure the controller to the type of tapping that the user wants to do. Something like this is what I a picturing.
      Menu Idea
       
      The G-Code in the program should look something like this, just like most other canned routines.
      Denford G84 Tapping Cycle
       
      If the user picks option
      A1 –     Z axis is not geared to the spindle
                  G84 – Spindle turns clockwise for Z – move
                  G84 – Spindle turns clockwise for Z+ move
                  G74 – Not sure if tapping head supports this?
       
      A2-        Z axis is not geared to the spindle
                  G84 – Spindle turns clockwise for Z – move
                  G84 – Spindle turns counter clockwise for Z+ move
                  G74 – Spindle turns counter clockwise for Z- move
                  G74 – Spindle turns clockwise for Z+ move
       
      A3-        Z axis is geared to the spindle
                  G84 – Spindle turns clockwise for Z – move
                  G84 – Spindle turns counter clockwise for Z+ move
                  G74 – Spindle turns counter clockwise for Z- move
                  G74 – Spindle turns clockwise for Z+ move
      Dan
       




      Group: DynoMotion Message: 10509 From: Dan Date: 11/13/2014
      Subject: Re: Tapping in KmotionCNC [2 Attachments]
      Attachments :
        Tom,
         
        Yes the Tension and compression tapping head does exactly what you thought. It is spring loaded in both extension and compression. These would be used when there is no encoder to sync the spindle with.
         
        My spindle currently is a Hitachi VFD, using an analog input for frequency (speed) and 2 inputs for CW/CCW. The motor I will use for rigid tapping is a 3 HP 8000 RPM Fanuc unit from a industrial CNC, and it will be fitted with a US Digital 500 line optical encoder. But that one needs an adapter plate made to mount it and one made for the encoder, it will be several weeks before I get those done.
         
        I have been looking at the Mach3 rigid tapping code, I think for the most part I got a handle on what is going on. But there are a couple things I am not understanding, and I have not had time to search for answers to them. The first is the reversing of the spindle, it looks like the spindle direction in this code is handled by commanding a positive or negative movement of the spindle axis, like it was a servo. Does this work with analog spindle control with a discrete input for both forward and reverse? My second unanswered item is how to read GCode Var Parameters into the c program?
         
        Here are 4 samples of the various ways the g code for tapping could be presented.
         

        S100 M3

        G98 G84 X-1. Y1. Z-1. R0.2 F0.03125 (G-Code with Thread Pitch, R plane is not used because of G98)

         

        S100 M3

        G98 G84 X-1. Y1. Z-1. R0.2 F3.125 (G-Code with actual feed rate, R plane is not used because of G98)

         

        S100 M3

        G99 G84 X-1. Y1. Z-1. R0.2 F0.03125 (G-Code with Thread Pitch, R plane is used as the retract height)

         

        S100 M3

        G99 G84 X-1. Y1. Z-1. R0.2 F3.125 (G-Code with actual feed rate, R plane is used as the retract height)

         

         
        Dan
         
        Sent: Tuesday, November 11, 2014 2:57 PM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]
         
         

        Hi Dan,
         
        I'm not familiar with a tension/compression head.  I'm assuming it provides some Z compliance so that exact synchronization is not required?
         
        I think we could use the same Rigid Tapping sequence for it.  If you don't have spindle feedback we could still used synchronized Z motion the same as if we did,  but just modify the code slightly to assume the actual Spindle Position is the same as the commanded Spindle Position.   The C Program here uses the commanded Spindle position (Dest) to slave the Z Motion.
         
         
        Let's get "Rigid" tapping to work first calling a C Prbefore we begin modifying the Interpreter.  This process will need to be modified to work with KMotionCNC instead of Mach3.  The Process just involves downloading the parameters for the Tap and then running the C Program Tap sequence.  KFLOP can simply read the GCode Var Parameters directly so there is no need to put them in DROs and download them the way the Mach3 process works.
         
        I forget how your Spindle is controlled.  Before we do anything we will need to configure things (open loop?) in a manner that we can tell the Spindle Axis to Move a certain amount (few revs) and then reverse a certain amount and it should move that amount approximately.  Do you know how to do this?
         
        Let me know how much of this makes sense.
         
        Regards
        TK
         
         
         
         
         
         
        Tom,
        Have you had any time to look into the tapping code? Even if the rigid tapping did not get worked out yet support for G84 and G74 for a tapping head or tension and compression tap head would be great. Right now I am using a Procunier tapping head and using a G85 and a reaming cycle. This works but the tapping head is huge and limits the size of part I can tap. To use a tension and compression tapping head the same canned cycle as G85 would work as a starting point and then reverse the spindle when the Z depth is reached. Then flip the spindle back to the original direction once the machine has reached the retract plane.
         
        If you do not have time to work on this right now, can you tell me what code file/s handle the processing of the G code canned cycles? Maybe I can give it a whirl.
         
        As for development of the rigid tapping code, I still have not been able to get my motor with encoder modified and installed. I am hoping by the first of the year now.
         
        Thanks,
        Dan
         
        Group: DynoMotion Message: 10510 From: Tom Kerekes Date: 11/13/2014
        Subject: Re: Tapping in KmotionCNC
        Hi Dan,

        Regarding Spindle Control.  I'm not sure if you want to go through the trouble of interfacing the Hitachi VFD if you are going to soon change it out.  To do the reversing with a Relay you would need a few line C program to watch the Servo Output, send the magnitude to a DAC, and sets the relay output bit based on the sign.

        Regarding accessing GCode Vars from KFLOP.  See the example KFLOPtoPCCmdExamples.c  The example uploads 3 numbers (doubles) to GCode Vars, runs an Interpreter command to add one to the first Var, then reads them back into KFLOP and prints them. 

            // put 3 double values in the persist vars
           
            SetUserDataDouble(10,123.456);
            SetUserDataDouble(11,1000.0);
            SetUserDataDouble(12,999.9);
           
            // transfer up to the GCode Vars
            SetVars(100,3,10);  // Upload 3 to GCode 100 from persist 10  
           
            MDI("#100 = [#100 + 1]");
               
            // read them back into different persist Vars
            GetVars(100,3,13);  // Download 3 from GCode 100 to persist 13
           
            printf("%f %f %f\n",GetUserDataDouble(13),GetUserDataDouble(14),GetUserDataDouble(15));

        Regards
        TK 


        From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
        To: DynoMotion@yahoogroups.com
        Sent: Thursday, November 13, 2014 11:34 AM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC

         
        Tom,
         
        Yes the Tension and compression tapping head does exactly what you thought. It is spring loaded in both extension and compression. These would be used when there is no encoder to sync the spindle with.
         
        My spindle currently is a Hitachi VFD, using an analog input for frequency (speed) and 2 inputs for CW/CCW. The motor I will use for rigid tapping is a 3 HP 8000 RPM Fanuc unit from a industrial CNC, and it will be fitted with a US Digital 500 line optical encoder. But that one needs an adapter plate made to mount it and one made for the encoder, it will be several weeks before I get those done.
         
        I have been looking at the Mach3 rigid tapping code, I think for the most part I got a handle on what is going on. But there are a couple things I am not understanding, and I have not had time to search for answers to them. The first is the reversing of the spindle, it looks like the spindle direction in this code is handled by commanding a positive or negative movement of the spindle axis, like it was a servo. Does this work with analog spindle control with a discrete input for both forward and reverse? My second unanswered item is how to read GCode Var Parameters into the c program?
         
        Here are 4 samples of the various ways the g code for tapping could be presented.
         
        S100 M3
        G98 G84 X-1. Y1. Z-1. R0.2 F0.03125 (G-Code with Thread Pitch, R plane is not used because of G98)
         
        S100 M3
        G98 G84 X-1. Y1. Z-1. R0.2 F3.125 (G-Code with actual feed rate, R plane is not used because of G98)
         
        S100 M3
        G99 G84 X-1. Y1. Z-1. R0.2 F0.03125 (G-Code with Thread Pitch, R plane is used as the retract height)
         
        S100 M3
        G99 G84 X-1. Y1. Z-1. R0.2 F3.125 (G-Code with actual feed rate, R plane is used as the retract height)
         
         
        Dan
         
        Sent: Tuesday, November 11, 2014 2:57 PM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]
         
         
        Hi Dan,
         
        I'm not familiar with a tension/compression head.  I'm assuming it provides some Z compliance so that exact synchronization is not required?
         
        I think we could use the same Rigid Tapping sequence for it.  If you don't have spindle feedback we could still used synchronized Z motion the same as if we did,  but just modify the code slightly to assume the actual Spindle Position is the same as the commanded Spindle Position.   The C Program here uses the commanded Spindle position (Dest) to slave the Z Motion.
         
         
        Let's get "Rigid" tapping to work first calling a C Prbefore we begin modifying the Interpreter.  This process will need to be modified to work with KMotionCNC instead of Mach3.  The Process just involves downloading the parameters for the Tap and then running the C Program Tap sequence.  KFLOP can simply read the GCode Var Parameters directly so there is no need to put them in DROs and download them the way the Mach3 process works.
         
        I forget how your Spindle is controlled.  Before we do anything we will need to configure things (open loop?) in a manner that we can tell the Spindle Axis to Move a certain amount (few revs) and then reverse a certain amount and it should move that amount approximately.  Do you know how to do this?
         
        Let me know how much of this makes sense.
         
        Regards
        TK
         
         
         
         
         
         
        Tom,
        Have you had any time to look into the tapping code? Even if the rigid tapping did not get worked out yet support for G84 and G74 for a tapping head or tension and compression tap head would be great. Right now I am using a Procunier tapping head and using a G85 and a reaming cycle. This works but the tapping head is huge and limits the size of part I can tap. To use a tension and compression tapping head the same canned cycle as G85 would work as a starting point and then reverse the spindle when the Z depth is reached. Then flip the spindle back to the original direction once the machine has reached the retract plane.
         
        If you do not have time to work on this right now, can you tell me what code file/s handle the processing of the G code canned cycles? Maybe I can give it a whirl.
         
        As for development of the rigid tapping code, I still have not been able to get my motor with encoder modified and installed. I am hoping by the first of the year now.
         
        Thanks,
        Dan
         

        From: "Tom Kerekes tk@... [DynoMotion]" <DynoMotion@yahoogroups.com>
        To: "DynoMotion@yahoogroups.com" <DynoMotion@yahoogroups.com>
        Sent: Wednesday, September 24, 2014 10:18 AM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]
         
         
        [Attachment(s) from Tom Kerekes included below]
        Hi Dan,

        Actually KFLOP samples the A B Quadrature lines at 16.67MHz and performs programmable filtering and counts quadrature transitions (counts).  The main limitation is that only +/-127 quadrature transitions can be counted per servo sample time of 90us.  This comes out to about 1.4M quadrature counts/sec.  We spec 1.0M quadrature counts/sec which is 250K encoder lines/sec.
         
        You should be good.
         
        Regards
        TK
         

         

        From: "'Dan' engnerdan@... [DynoMotion]" <DynoMotion@yahoogroups.com>
        To: DynoMotion@yahoogroups.com
        Sent: Wednesday, September 24, 2014 5:36 AM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC
         
         
        Tom,
        Just a little update, I have 2 spindle motors on the way to me and I am going to order some optical encoders this afternoon. But I want to verify something with you first.
         
        I have a 6000 RPM and a 8000 RPM motor coming, I was planning on using 1000 line optical encoders. I think you said the sampling rate for the encoder channels is 1Mhz, is tat correct? I want to verify how that sampling works.
         
        6000 RPM motor with a 1000 line encoder (4000 line w quadrature)
        6000 RPM/ 60 Seconds = 100 Rotations per second
        100 Rotations per second * 1000 lines per rotation = 100,000hz or 100Khz single rate per channel
         
        So the sampling needed for this setup is only 100Khz correct? The 4X multiplication for the quadrature happens after the signal is sampled, right? Or is the sampling needed 200Khz because the rising and falling edge need to be detected?
         
         
        Dan
         


        Sent: Wednesday, September 17, 2014 8:36 AM
        Subject: Re: [DynoMotion] Tapping in KmotionCNC
         
         
        Tom,
        I have been swamped with work, school and getting ready for a wedding so this is a bit delayed. Here is what I have so far. I could be wrong but I don’t think it will take a ton of work on your end in coding to make this happen. I need to find some more info on the structure of the G84 command (how it is put together in the g-code file). But from the small amount I know I think it follows the convention of most other canned cycles.
        I can test your code when you get it done, but I have one small hangup right now. My spindle motor went up in smoke last week and I am running on a temporary motor. So I will not be able to do any rigid tapping testing until the new motor comes and I get an encoder installed.
         
         
         
        I did a fair amount of internet searching and talked to a few friends who program CNC’s daily. Here is a compilation of what I have found.
        G Codes for tapping
        G33.1
        G33.2
        G74 – Non rigid tapping Left Hand
        G74.1 – Rigid Tapping Left Hand -
        G.84 – Generic Tapping G-Code
        G84.1 – Right hand Rigid tapping - Mazak
        G84.2 – Right Hand rigid tapping
        G84.3 – Left hand Rigid tapping
        Plus there may be more and there are combinations of G-codes to comprise different tapping cycles. Write or wrong I am thinking either we use just G74 and G84 or have it a programmable value for an initialization file. Where the end user would tell the KFLOP which G-code is left hand and which is right hand.
         
        The next thing I found was the F value of the canned cycle can have 2 different values. One version has the F value equal to the thread pitch (1/4-20 would be 0.050”). The second F value is an actual inches per minute for the Z axis. This would be calculated by multiplying the thread pitch times the spindle RPM.
         
        The next variable is the type of tapping, old school tapping would have been done with a automatically reversing tapping head. The spindle turns clockwise the entire cycle and the tapping head reverses when the Z axis retracts. Then there is the tension & compression tapping head that allows for a non-synchronized Z axis feed. The last type is rigid tapping.
         
        I am thinking that we use the generic G74 and G84 G-Codes like I mentioned before. Then you add a set of parameters to configure the controller to the type of tapping that the user wants to do. Something like this is what I a picturing.
        Menu Idea
         
        The G-Code in the program should look something like this, just like most other canned routines.
        Denford G84 Tapping Cycle
         
        If the user picks option
        A1 –     Z axis is not geared to the spindle
                    G84 – Spindle turns clockwise for Z – move
                    G84 – Spindle turns clockwise for Z+ move
                    G74 – Not sure if tapping head supports this?
         
        A2-        Z axis is not geared to the spindle
                    G84 – Spindle turns clockwise for Z – move
                    G84 – Spindle turns counter clockwise for Z+ move
                    G74 – Spindle turns counter clockwise for Z- move
                    G74 – Spindle turns clockwise for Z+ move
         
        A3-        Z axis is geared to the spindle
                    G84 – Spindle turns clockwise for Z – move
                    G84 – Spindle turns counter clockwise for Z+ move
                    G74 – Spindle turns counter clockwise for Z- move
                    G74 – Spindle turns clockwise for Z+ move
        Dan
         






        Group: DynoMotion Message: 10511 From: Dan Date: 11/13/2014
        Subject: Re: Tapping in KmotionCNC [2 Attachments]
        Attachments :
          Tom,
          Thanks for the quick reply.
           
          I am not changing the Hitachi motor drive, just the motor. But your explanation confirms what I was thinking. That is I would need to manually change the direction in the C program.
           
          I will look at that code example and see if I can wrap my head around how it is working. I will keep you posted on my results
           
           
          Thanks,
          Dan
           
          Sent: Thursday, November 13, 2014 1:52 PM
          Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]
           
           

          Hi Dan,

          Regarding Spindle Control.  I'm not sure if you want to go through the trouble of interfacing the Hitachi VFD if you are going to soon change it out.  To do the reversing with a Relay you would need a few line C program to watch the Servo Output, send the magnitude to a DAC, and sets the relay output bit based on the sign.

          Regarding accessing GCode Vars from KFLOP.  See the example KFLOPtoPCCmdExamples.c  The example uploads 3 numbers (doubles) to GCode Vars, runs an Interpreter command to add one to the first Var, then reads them back into KFLOP and prints them. 

              // put 3 double values in the persist vars
             
              SetUserDataDouble(10,123.456);
              SetUserDataDouble(11,1000.0);
              SetUserDataDouble(12,999.9);
             
              // transfer up to the GCode Vars
              SetVars(100,3,10);  // Upload 3 to GCode 100 from persist 10  
             
              MDI("#100 = [#100 + 1]");
                 
              // read them back into different persist Vars
              GetVars(100,3,13);  // Download 3 from GCode 100 to persist 13
             
              printf("%f %f %f\n",GetUserDataDouble(13),GetUserDataDouble(14),GetUserDataDouble(15));

          Regards
          TK 
           
          Group: DynoMotion Message: 10628 From: engnerdan Date: 12/2/2014
          Subject: Re: Tapping in KmotionCNC [2 Attachments]
          Tom, 
          I am still picking away at the code for rigid tapping. I thinking I have figured out the example of how to read the g code into a C program. But I have more questions before I can move on. 

          I have attached a non-working bit of code, only to show what I came up with in the main() section for retrieving the g code variables into the C program. 

          Question 1. 
          Using the "GetVars" function you had in your code examples. I don't see how variations in the g code format can be taken into account. 

          Example
          I am basing the code I write on a g code like looking like this 
          G84  X-1. Y1. Z-1. R0.2 F0.03125

          But what if the X and Y values are not given or if the "R" value is left out? 
          G84 Z-1. R0.2 F0.03125
          G84  X-1. Y1. Z-1. F0.03125



          Question 2. 
          How do I get the Z value from which the tapping starts? Like in this example code, we are starting 1.25" above the Z0 plane and tapping from there down to Z0.5. 

          Example code
          G01 X1.5 Y1.5 Z1.25
          G84 Xa.5 Y1.5 Z0.5 R.2 F0.03125


          Question 3. 
          How do I read in the current commanded spindle RPM into the c program. So if the g code tells KMotionCNC S100 but the operator has the spindle override at 2X. The commanded speed is not 200RPM, is there a way read in what KMotionCNC thinks the spindle RPM is supposed to be? 


          Thanks,
          Dan


          ---In DynoMotion@yahoogroups.com, <engnerdan@...> wrote :

          Tom,
          Thanks for the quick reply.
           
          I am not changing the Hitachi motor drive, just the motor. But your explanation confirms what I was thinking. That is I would need to manually change the direction in the C program.
           
          I will look at that code example and see if I can wrap my head around how it is working. I will keep you posted on my results
           
           
          Thanks,
          Dan
           
          Sent: Thursday, November 13, 2014 1:52 PM
          Subject: Re: [DynoMotion] Tapping in KmotionCNC [2 Attachments]
           
           

          Hi Dan,

          Regarding Spindle Control.  I'm not sure if you want to go through the trouble of interfacing the Hitachi VFD if you are going to soon change it out.  To do the reversing with a Relay you would need a few line C program to watch the Servo Output, send the magnitude to a DAC, and sets the relay output bit based on the sign.

          Regarding accessing GCode Vars from KFLOP.  See the example KFLOPtoPCCmdExamples.c  The example uploads 3 numbers (doubles) to GCode Vars, runs an Interpreter command to add one to the first Var, then reads them back into KFLOP and prints them. 

              // put 3 double values in the persist vars
             
              SetUserDataDouble(10,123.456);
              SetUserDataDouble(11,1000.0);
              SetUserDataDouble(12,999.9);
             
              // transfer up to the GCode Vars
              SetVars(100,3,10);  // Upload 3 to GCode 100 from persist 10  
             
              MDI("#100 = [#100 + 1]");
                 
              // read them back into different persist Vars
              GetVars(100,3,13);  // Download 3 from GCode 100 to persist 13
             
              printf("%f %f %f\n",GetUserDataDouble(13),GetUserDataDouble(14),GetUserDataDouble(15));

          Regards
          TK 
           
          Group: DynoMotion Message: 10635 From: Tom Kerekes Date: 12/3/2014
          Subject: Re: Tapping in KmotionCNC [2 Attachments]
          Hi Dan,

          No that isn't the way to read GCode into a C Program.  It is reading GCode Variables.  GCode Variables are different than the "words" in a Gcode line.

          The function:

              GetVars(100,3,13);  // Download 3 from GCode 100 to persist 13
          Reads 3 GCode Variables #100 #101 #102 into KFLOP double persist variables 13, 14, 15.

          Are you familiar with GCode Variables?  They are sort of like memory variables on a calculator.  The Interpreter has 5400 of them.  Some have special functionality (values > 5000) but many are for general use.

          As I said before as a first step let's not worry about creating the G84 Gcode or modifying the GCode Interpreter yet.  Let's do that after we demonstrate that we can successfully do rigid tapping.  Let's start doing things just like what works in Mach3 for Rigid Tapping.  This will also allow us to be on the same page as to what types and variations of Rigid tapping you think are required.  See:


          In this case we write GCode to put all the necessary parameters for the Tap into GCode Variables with something like:

          #10=20 (TPI - Threads per inch)
          #11=700 (Forward Cutting RPM)
          #12=1000 (Retract RPM)
          #13=0.75 (Z depth Total inches)
          #14=0.2 (Z depth Forward per Motion)
          #15=0.05 (Z depth Retract per Motion)

          Let's assume this is sufficient to define what the Rigid Tapping Sequence should do.

          Next we can invoke an M code to run a program in KFLOP to read all these parameters and do the Tap.  The Mach3 example used Mcode 84 because it is the same number as G84 that is often used for Rigid Tapping.  But KMotionCNC doesn't allow M84 to be used so let's use M100 instead which is able to be configured to run a C Program in KFLOP.  Note this is only a test.  Later after everything works we will change the GCode Interpreter so that a line of G84 can do the same thing.

          So after the above GCode we would add:

          M100

          Set the Tool Setup to configure M100 to execute your program "DLW - Rigid Tapping.c"

          The first thing the C program should do is download the GCode Vars.  Mach3 downloaded those 6 values into persist Variables 12-23 (which as double words would be 6-11).  So let's download them to the same KFLOP persist variables with:

              GetVars(10,6,6);  // Download 6 values from GCode #10-15 to persist 6-11

          Then lets print the 6 values to see if that much is working so far:

              printf("%f %f %f %f %f %f\n",GetUserDataDouble(6),GetUserDataDouble(7),GetUserDataDouble(8),GetUserDataDouble(9),GetUserDataDouble(10),GetUserDataDouble(11));

          Please try that as a first step and let me know how much of this makes sense.
          Regards
          TK












          Group: DynoMotion Message: 14231 From: engnerdan Date: 12/6/2016
          Subject: Re: Tapping in KmotionCNC [2 Attachments]
          Tom,
          I am going to drive back into this rigid tapping work (after a two year delay). I will do everything you talked about in your previous reply and post back here.

          In the time since I started this topic I have run several commercial/industrial CNC mills and tried to observe how they handle rigid tapping. Which I have found they are blocking out any feedrate overrides or feedrate and spindle overrides when they enter a rigid tapping cycle. Additionally they are disabling a feedhold being issued while the tapping cycle is happening. Is this already implemented in KMOTION for a lathe installation with single point threading? If so is it possible to block a feedrate or spindle override (set it to 100%) and block a feedhold from a C-program?

          Dan
          Group: DynoMotion Message: 14232 From: Tom Kerekes Date: 12/6/2016
          Subject: Re: Tapping in KmotionCNC

          Hi Dan,

          No I believe most of that would need to be added if needed.

          I would think that you may want SSO for single point Threading.

          Rigid Tapping is performed by a C Program basically performing an Independent Spindle Motion ie.  MoveRelAtVel(SPINDLE_AXIS, Dist*TPI*CNTS_PER_REV, Rate*TPI*CNTS_PER_REV); while the Z axis is following the spindle using Independent MoveExp() calls.  I believe this should run unaffected by SSO or FRO changes.  Feedhold might also make sense while rigid tapping.  Feedhold only affects the Axes included in the Coordinated Motion System.

          Regards

          TK



          On 12/6/2016 11:31 AM, engnerdan@... [DynoMotion] wrote:
           

          Tom,
          I am going to drive back into this rigid tapping work (after a two year delay). I will do everything you talked about in your previous reply and post back here.

          In the time since I started this topic I have run several commercial/industrial CNC mills and tried to observe how they handle rigid tapping. Which I have found they are blocking out any feedrate overrides or feedrate and spindle overrides when they enter a rigid tapping cycle. Additionally they are disabling a feedhold being issued while the tapping cycle is happening. Is this already implemented in KMOTION for a lathe installation with single point threading? If so is it possible to block a feedrate or spindle override (set it to 100%) and block a feedhold from a C-program?

          Dan


          Group: DynoMotion Message: 14236 From: mmurray70@hotmail.com Date: 12/6/2016
          Subject: Re: Tapping in KmotionCNC [2 Attachments]
          Hi Dan,

          I blocked feedhold from my toolchange program. I setup my machine so pushing feedhold external button sets a variable, and i set a persist.UserData variable in my toolchange program to prevent feedhold, and i check both these variables in my forever loop and then apply feedhold. 

          Another huge bonus of doing it this way is it remembers if you push feedhold while executing a C program. It seemed to ignore feedhold for me if it was pushed while spindle was ramping up. And pushing it before while toolchanging would have caused my toolchanger to crash. Now i can push feedhold during a spindle ramp up and safely during a toolchange without messing it up, and feedhold is applied automatically on the first move. Heres the code i used, may not be perfect, but it works: 

          if (ReadBit(1038)) persist.UserData[160] = 1; // If Feedhold button pushed set feedhold variable to 1
          // If Fhold var is 1, any axis moves, toolchanger done and job active then stop motion
          if (persist.UserData[160] == 1 && CheckDoneXYZABC && !persist.UserData[161] && JOB_ACTIVE) StopCoordinatedMotion(); 
          if (ReadBit(1037)) // if cycle start button pushed
          {
          persist.UserData[160] = 0; // Disable feedhold variable
          ResumeCoordinatedMotion(); // Resume motion
          }

          Also, all the machines i have used (fanuc and mazak) also ignore feed and speed overrides and feedholds. Once you start you cant stop. Good luck with it. 

          Mark
           
          Group: DynoMotion Message: 14240 From: engnerdan Date: 12/7/2016
          Subject: Re: Tapping in KmotionCNC
          Your timing with this reply is ironic because at the same time I was implementing the same thing for a different reason. I have not cared for how the ExternalButtons.c example code handled the FeedHold operation because if I accidentally double pressed the FeedHold switch I was no longer in FeedHold.

          So last night I rewrote the example code and planned to share it today. But while I was falling asleep last night I realized that having a bit for the feedhold state was beneficial for other purposes, like a tower light to indicate the machine is in a feedhold.

          Its early and I am not wrapping my head around your other state tests in your code, but I will look at it again later.

          -Dan